package com.worldstear.utils;

import cn.hutool.setting.dialect.Props;

import java.util.Optional;

public class PropKit {
    private static Props props = new Props("application.yml");

    public static String getStr(String key) {
        return Optional.ofNullable(props.getStr(key)).orElse("").trim();
    }

    public static Integer getInt(String key) {
        try {
            return Integer.parseInt(getStr(key));
        }catch (Exception e) {
            return null;
        }
    }

    public static Boolean getBoolean(String key) {
        return props.getBool(key);
    }

    public static Boolean getBoolean(String key, boolean defaultValue) {
        return props.getBool(key, defaultValue);
    }

    public static void use(String path) {
        props = new Props(path);
    }
}
